package com.yonyou.pmclouds.discuss.rmiimpl;

import com.alibaba.dubbo.config.annotation.Service;
import com.yonyou.pmclouds.ApplicationConsts;
import com.yonyou.pmclouds.basecom.exception.BusinessException;
import com.yonyou.pmclouds.discuss.entity.DiscussNoticeVO;
import com.yonyou.pmclouds.discuss.entity.DiscussionVO;
import com.yonyou.pmclouds.discuss.impl.DiscussProcessor;
import com.yonyou.pmclouds.discuss.itf.DiscussInternalOperation;
import com.yonyou.pmclouds.discuss.itf.DiscussNoticeInternalOperation;
import com.yonyou.pmclouds.discuss.rmiitf.DiscussMaintain;
import org.springframework.beans.factory.annotation.Autowired;

@Service(version = ApplicationConsts.APPLICATION_VERSION, interfaceClass = DiscussMaintain.class)
public class DiscussMaintainImpl implements DiscussMaintain {
    @Autowired
    private DiscussInternalOperation discussOperation;
    @Autowired
    private DiscussNoticeInternalOperation noticeOperation;
    @Autowired
    private DiscussProcessor discussProcessor;

    @Override
    public void makeDiscussion(DiscussionVO discussion) throws BusinessException {
        // 存储discuss
        discussOperation.insertDiscussion(discussion);
        // 获取通知人员及通知标题
        DiscussNoticeVO[] notices = discussProcessor.generateNotice(discussion);
        // 存储通知
        noticeOperation.insertNotices(notices);
    }

    @Override
    public void makeNoticeRead(String noticeId, String userId) throws BusinessException {
        noticeOperation.makeNoticeRead(noticeId, userId);
    }

}
